<?php

namespace App\V3\V3_1\Models;

use App\Api\Models\OverflowBreakagePackageModel;
use Illuminate\Database\Eloquent\Model;
use DateTimeInterface;

/**
 * 报溢报损主单
 * Class OverflowBreakageModel
 * @package App\Models
 */
class OverflowBreakageModel extends Model
{
    protected $table = 'overflow_breakage';

    protected $dateFormat = 'U';//这个时间字段被为被格式化为UNIX 时间戳的形式存储
    //toArray 时间转换问题
    protected function serializeDate(DateTimeInterface $date)
    {
        return $date->format('Y-m-d H:i:s');
    }

    public function goodsInfo()
    {
        return self::hasMany(OverflowBreakageDetailModel::class, 'o_b_main_id', 'id');
    }

    public function packageInfo()
    {
        return self::hasMany(OverflowBreakagePackageModel::class, 'o_b_main_id', 'id');
    }

    public function checkInfo()
    {
        return self::hasMany(OverflowBreakageChecksModel::class, 'o_b_main_id', 'id');
    }
}
